#! /bin/bash
export LANG=en_US.UTF-8

pid=$*

ports=`netstat -lntp|grep $pid|awk '{print $4}'|awk -F ':' '{print $NF}'`
p_number=`echo $ports|awk '{print NF}'`
if [ "$p_number" -gt 1 ];then
        echo $ports|awk '{if($1>$2){print $2}else{print $1}}'
else
        echo $ports
fi